var ct = {};
var tc = new AMap.LngLat(108.95269, 34.904533);
ct.Map = function(id, options) {
    this.map = new AMap.Map(id, {
        mapStyle: 'amap://styles/normal', //设置地图的显示样式
        center: tc,
        zoom: 10, //地图显示的缩放级
        pitch: 60, // 地图俯仰角度，有效范围 0 度- 83 度
        viewMode: '3D', // 地图模式
    });
    // var district = null;
    // var polygons = [];

    // function drawBounds() {
    //     //加载行政区划插件
    //     if (!district) {
    //         //实例化DistrictSearch
    //         var opts = {
    //             subdistrict: 0, //获取边界不需要返回下级行政区
    //             extensions: 'all', //返回行政区边界坐标组等具体信息
    //             level: 'district' //查询行政级别为 市
    //         };
    //         district = new AMap.DistrictSearch(opts);
    //     }
    //     //行政区查询
    //     district.setLevel(document.getElementById('level').value)
    //     district.search(document.getElementById('district').value, function(status, result) {
    //         map.remove(polygons) //清除上次结果
    //         polygons = [];
    //         var bounds = result.districtList[0].boundaries;
    //         if (bounds) {
    //             for (var i = 0, l = bounds.length; i < l; i++) {
    //                 //生成行政区划polygon
    //                 var polygon = new AMap.Polygon({
    //                     strokeWeight: 1,
    //                     path: bounds[i],
    //                     fillOpacity: 0.4,
    //                     fillColor: '#80d8ff',
    //                     strokeColor: '#0091ea'
    //                 });
    //                 polygons.push(polygon);
    //             }
    //         }
    //         map.add(polygons)
    //         map.setFitView(polygons); //视口自适应
    //     });
    // }
    // drawBounds();
    // document.getElementById('draw').onclick = drawBounds;
    // document.getElementById('district').onkeydown = function(e) {
    //     if (e.keyCode === 13) {
    //         drawBounds();
    //         return false;
    //     }
    //     return true;
    // };
    var _this = this;
    var contextMenu = new AMap.ContextMenu();
    contextMenu.addItem("幻影黑", function() {
        _this.map.setMapStyle('amap://styles/dark');
    }, 7);

    contextMenu.addItem("月光银", function() {
        _this.map.setMapStyle('amap://styles/light');
    }, 1);

    contextMenu.addItem("远山黛", function() {
        _this.map.setMapStyle('amap://styles/whitesmoke');
    }, 2);

    contextMenu.addItem("雅士灰", function(e) {
        _this.map.setMapStyle('amap://styles/grey');
    }, 3);

    contextMenu.addItem("极夜蓝", function(e) {
        _this.map.setMapStyle('amap://styles/darkblue');
    }, 4);

    contextMenu.addItem("马卡龙", function(e) {
        _this.map.setMapStyle('amap://styles/macaron');
    }, 5);

    contextMenu.addItem("草色青", function(e) {
        _this.map.setMapStyle('amap://styles/fresh');
    }, 6);

    contextMenu.addItem("标准", function(e) {
        _this.map.setMapStyle('amap://styles/normal');
    }, 0);

    _this.map.on('rightclick', function(e) {
        contextMenu.open(_this.map, e.lnglat);
    });

    this.addSubLine = function() {
        // 折线的节点坐标数组，每个元素为 AMap.LngLat 对象
        // 10号线
        var path_ten = [
            new AMap.LngLat(116.294, 39.9742),
            new AMap.LngLat(116.306, 39.9756),
            new AMap.LngLat(116.318, 39.976),
            new AMap.LngLat(116.329, 39.9763),
            new AMap.LngLat(116.34, 39.9765),
            new AMap.LngLat(116.354, 39.9762),
            new AMap.LngLat(116.37, 39.9763),
            new AMap.LngLat(116.381, 39.9767),
            new AMap.LngLat(116.394, 39.9769),
            new AMap.LngLat(116.406, 39.977),
            new AMap.LngLat(116.418, 39.977),
            new AMap.LngLat(116.436, 39.9779),
            new AMap.LngLat(116.448, 39.9727),
            new AMap.LngLat(116.457, 39.9614),
            new AMap.LngLat(116.462, 39.9494),
            new AMap.LngLat(116.462, 39.9416),
            new AMap.LngLat(116.462, 39.9337),
            new AMap.LngLat(116.462, 39.9232),
            new AMap.LngLat(116.462, 39.9167),
            new AMap.LngLat(116.46, 39.9084),
            new AMap.LngLat(116.462, 39.8935),
            new AMap.LngLat(116.461, 39.8844),
            new AMap.LngLat(116.461, 39.8755),
            new AMap.LngLat(116.458, 39.8659),
            new AMap.LngLat(116.454, 39.8519),
            new AMap.LngLat(116.447, 39.8459),
            new AMap.LngLat(116.428, 39.8457),
            new AMap.LngLat(116.414, 39.8459),
            new AMap.LngLat(116.399, 39.8454),
            new AMap.LngLat(116.385, 39.8451),
            new AMap.LngLat(116.371, 39.8459),
            new AMap.LngLat(116.351, 39.8459),
            new AMap.LngLat(116.333, 39.8444),
            new AMap.LngLat(116.32, 39.8445),
            new AMap.LngLat(116.305, 39.8499),
            new AMap.LngLat(116.304, 39.8582),
            new AMap.LngLat(116.304, 39.8665),
            new AMap.LngLat(116.303, 39.8803),
            new AMap.LngLat(116.31, 39.8977),
            new AMap.LngLat(116.31, 39.9075),
            new AMap.LngLat(116.298, 39.9233),
            new AMap.LngLat(116.294, 39.933),
            new AMap.LngLat(116.294, 39.9481),
            new AMap.LngLat(116.294, 39.9583),
            new AMap.LngLat(116.289, 39.966),
            new AMap.LngLat(116.294, 39.9742)
        ];
        //2号线
        var path_two = [
            new AMap.LngLat(116.373, 39.9487),
            new AMap.LngLat(116.394, 39.948),
            new AMap.LngLat(116.408, 39.9492),
            new AMap.LngLat(116.417, 39.9487),
            new AMap.LngLat(116.435, 39.9424),
            new AMap.LngLat(116.434, 39.9337),
            new AMap.LngLat(116.433, 39.9244),
            new AMap.LngLat(116.436, 39.9086),
            new AMap.LngLat(116.427, 39.905),
            new AMap.LngLat(116.419, 39.9008),
            new AMap.LngLat(116.398, 39.9002),
            new AMap.LngLat(116.384, 39.9001),
            new AMap.LngLat(116.374, 39.8998),
            new AMap.LngLat(116.363, 39.8994),
            new AMap.LngLat(116.357, 39.9072),
            new AMap.LngLat(116.356, 39.9235),
            new AMap.LngLat(116.355, 39.9324),
            new AMap.LngLat(116.353, 39.942),
            new AMap.LngLat(116.373, 39.9487)

        ];

        //13号线
        var path_thirteen = [
            new AMap.LngLat(116.353, 39.942),
            new AMap.LngLat(116.345, 39.9666),
            new AMap.LngLat(116.34, 39.9765),
            new AMap.LngLat(116.338, 39.9929),
            new AMap.LngLat(116.32, 40.033),
            new AMap.LngLat(116.306, 40.0531),
            new AMap.LngLat(116.319, 40.0709),
            new AMap.LngLat(116.336, 40.0708),
            new AMap.LngLat(116.361, 40.0705),
            new AMap.LngLat(116.411, 40.0527),
            new AMap.LngLat(116.435, 40.043),
            new AMap.LngLat(116.447, 39.995),
            new AMap.LngLat(116.436, 39.9779),
            new AMap.LngLat(116.432, 39.9684),
            new AMap.LngLat(116.433, 39.9583),
            new AMap.LngLat(116.435, 39.9424)

        ];
        //房山线
        var path_fs = [
            new AMap.LngLat(116.125, 39.7233),
            new AMap.LngLat(116.141, 39.7233),
            new AMap.LngLat(116.156, 39.7232),
            new AMap.LngLat(116.176, 39.7232),
            new AMap.LngLat(116.184, 39.73),
            new AMap.LngLat(116.185, 39.748),
            new AMap.LngLat(116.19, 39.7606),
            new AMap.LngLat(116.213, 39.7638),
            new AMap.LngLat(116.219, 39.7948),
            new AMap.LngLat(116.291, 39.8076),
            new AMap.LngLat(116.302, 39.8144)

        ];
        //昌平线
        var path_cp = [
            new AMap.LngLat(116.287, 40.2071),
            new AMap.LngLat(116.28, 40.1647),
            new AMap.LngLat(116.289, 40.1483),
            new AMap.LngLat(116.294, 40.1309),
            new AMap.LngLat(116.314, 40.1043),
            new AMap.LngLat(116.294, 40.0949),
            new AMap.LngLat(116.306, 40.0531)

        ];
        //9号线
        var path_nine = [
            new AMap.LngLat(116.302, 39.8144),
            new AMap.LngLat(116.297, 39.8252),
            new AMap.LngLat(116.298, 39.8324),
            new AMap.LngLat(116.297, 39.8414),
            new AMap.LngLat(116.294, 39.8553),
            new AMap.LngLat(116.294, 39.8675),
            new AMap.LngLat(116.303, 39.8803),
            new AMap.LngLat(116.315, 39.887),
            new AMap.LngLat(116.321, 39.895),
            new AMap.LngLat(116.324, 39.9074),
            new AMap.LngLat(116.326, 39.9239),
            new AMap.LngLat(116.325, 39.933),
            new AMap.LngLat(116.325, 39.9432)

        ];
        //八通线
        var path_bt = [
            new AMap.LngLat(116.496, 39.9088),
            new AMap.LngLat(116.515, 39.9085),
            new AMap.LngLat(116.532, 39.9095),
            new AMap.LngLat(116.555, 39.9092),
            new AMap.LngLat(116.577, 39.9103),
            new AMap.LngLat(116.599, 39.9092),
            new AMap.LngLat(116.618, 39.9059),
            new AMap.LngLat(116.637, 39.9037),
            new AMap.LngLat(116.646, 39.8933),
            new AMap.LngLat(116.658, 39.8902),
            new AMap.LngLat(116.668, 39.8838),
            new AMap.LngLat(116.679, 39.8754),
            new AMap.LngLat(116.686, 39.872)

        ];
        //1号线
        var path_one = [
            new AMap.LngLat(116.178, 39.9263),
            new AMap.LngLat(116.19, 39.9074),
            new AMap.LngLat(116.213, 39.9074),
            new AMap.LngLat(116.236, 39.9074),
            new AMap.LngLat(116.253, 39.9074),
            new AMap.LngLat(116.274, 39.9075),
            new AMap.LngLat(116.295, 39.9075),
            new AMap.LngLat(116.31, 39.9075),
            new AMap.LngLat(116.324, 39.9074),
            new AMap.LngLat(116.338, 39.9074),
            new AMap.LngLat(116.352, 39.9072),
            new AMap.LngLat(116.357, 39.9072),
            new AMap.LngLat(116.376, 39.9072),
            new AMap.LngLat(116.392, 39.9075),
            new AMap.LngLat(116.402, 39.9078),
            new AMap.LngLat(116.412, 39.9081),
            new AMap.LngLat(116.418, 39.9083),
            new AMap.LngLat(116.436, 39.9086),
            new AMap.LngLat(116.45, 39.9085),
            new AMap.LngLat(116.46, 39.9084),
            new AMap.LngLat(116.478, 39.9083),
            new AMap.LngLat(116.496, 39.9088),
            new AMap.LngLat(116.515, 39.9085)

        ];
        //亦庄线
        var path_yz = [
            new AMap.LngLat(116.428, 39.8457),
            new AMap.LngLat(116.448, 39.8343),
            new AMap.LngLat(116.46, 39.828),
            new AMap.LngLat(116.461, 39.8071),
            new AMap.LngLat(116.48, 39.803),
            new AMap.LngLat(116.491, 39.8068),
            new AMap.LngLat(116.505, 39.8031),
            new AMap.LngLat(116.513, 39.7932),
            new AMap.LngLat(116.522, 39.783),
            new AMap.LngLat(116.54, 39.7731),
            new AMap.LngLat(116.562, 39.7837),
            new AMap.LngLat(116.581, 39.7951),
            new AMap.LngLat(116.591, 39.8034)

        ];
        //5号线-在建
        var path_five = [
            new AMap.LngLat(116.428, 39.8457),
            new AMap.LngLat(116.422, 39.8576),
            new AMap.LngLat(116.422, 39.8657),
            new AMap.LngLat(116.421, 39.8831),
            new AMap.LngLat(116.419, 39.8931),
            new AMap.LngLat(116.419, 39.9008),
            new AMap.LngLat(116.418, 39.9083),
            new AMap.LngLat(116.418, 39.9172),
            new AMap.LngLat(116.417, 39.9244),
            new AMap.LngLat(116.417, 39.9337),
            new AMap.LngLat(116.417, 39.9409),
            new AMap.LngLat(116.417, 39.9487),
            new AMap.LngLat(116.419, 39.9587),
            new AMap.LngLat(116.418, 39.9685),
            new AMap.LngLat(116.418, 39.977),
            new AMap.LngLat(116.417, 39.9878),
            new AMap.LngLat(116.417, 40.0038),
            new AMap.LngLat(116.418, 40.0306),
            new AMap.LngLat(116.415, 40.0419),
            new AMap.LngLat(116.411, 40.0527),
            new AMap.LngLat(116.413, 40.0664),
            new AMap.LngLat(116.413, 40.0754),
            new AMap.LngLat(116.413, 40.0834)

        ];
        //7号线
        var path_seven = [
            new AMap.LngLat(116.536, 39.85),
            new AMap.LngLat(116.521, 39.8575),
            new AMap.LngLat(116.512, 39.8609),
            new AMap.LngLat(116.5, 39.8685),
            new AMap.LngLat(116.501, 39.8748),
            new AMap.LngLat(116.507, 39.8893),
            new AMap.LngLat(116.501, 39.8931),
            new AMap.LngLat(116.489, 39.8932),
            new AMap.LngLat(116.478, 39.8932),
            new AMap.LngLat(116.449, 39.8936),
            new AMap.LngLat(116.435, 39.8936),
            new AMap.LngLat(116.419, 39.8931),
            new AMap.LngLat(116.406, 39.8926),
            new AMap.LngLat(116.398, 39.8912),
            new AMap.LngLat(116.385, 39.8895),
            new AMap.LngLat(116.374, 39.8893),
            new AMap.LngLat(116.359, 39.8894),
            new AMap.LngLat(116.335, 39.8899),
            new AMap.LngLat(116.329, 39.8898),
            new AMap.LngLat(116.321, 39.895)

        ];
        //8号线-在建
        var path_eight = [
            new AMap.LngLat(116.403, 39.9331),
            new AMap.LngLat(116.396, 39.9374),
            new AMap.LngLat(116.394, 39.948),
            new AMap.LngLat(116.395, 39.9693),
            new AMap.LngLat(116.394, 39.9769),
            new AMap.LngLat(116.394, 39.9857),
            new AMap.LngLat(116.393, 40.0023),
            new AMap.LngLat(116.393, 40.01),
            new AMap.LngLat(116.373, 40.0219),
            new AMap.LngLat(116.355, 40.0376),
            new AMap.LngLat(116.352, 40.0469),
            new AMap.LngLat(116.347, 40.0603),
            new AMap.LngLat(116.361, 40.0705),
            new AMap.LngLat(116.363, 40.0812),
            new AMap.LngLat(116.35, 40.0906),
            new AMap.LngLat(116.327, 40.0878),
            new AMap.LngLat(116.314, 40.1043)

        ];
        //4号线-大兴线
        var path_four = [
            new AMap.LngLat(116.32, 39.6702),
            new AMap.LngLat(116.322, 39.6866),
            new AMap.LngLat(116.319, 39.7125),
            new AMap.LngLat(116.333, 39.723),
            new AMap.LngLat(116.333, 39.7318),
            new AMap.LngLat(116.333, 39.7427),
            new AMap.LngLat(116.332, 39.7535),
            new AMap.LngLat(116.332, 39.7635),
            new AMap.LngLat(116.331, 39.7736),
            new AMap.LngLat(116.329, 39.7896),
            new AMap.LngLat(116.366, 39.8123),
            new AMap.LngLat(116.371, 39.837),
            new AMap.LngLat(116.371, 39.8459),
            new AMap.LngLat(116.371, 39.8533),
            new AMap.LngLat(116.379, 39.8652),
            new AMap.LngLat(116.374, 39.8786),
            new AMap.LngLat(116.374, 39.8893),
            new AMap.LngLat(116.374, 39.8998),
            new AMap.LngLat(116.376, 39.9072),
            new AMap.LngLat(116.374, 39.9161),
            new AMap.LngLat(116.373, 39.9242),
            new AMap.LngLat(116.372, 39.9327),
            new AMap.LngLat(116.368, 39.9407),
            new AMap.LngLat(116.353, 39.942),
            new AMap.LngLat(116.339, 39.9383),
            new AMap.LngLat(116.325, 39.9432),
            new AMap.LngLat(116.323, 39.9578),
            new AMap.LngLat(116.321, 39.9669),
            new AMap.LngLat(116.318, 39.976),
            new AMap.LngLat(116.316, 39.9839),
            new AMap.LngLat(116.316, 39.9921),
            new AMap.LngLat(116.31, 39.9995),
            new AMap.LngLat(116.291, 39.9983),
            new AMap.LngLat(116.278, 40.0024),
            new AMap.LngLat(116.27, 40.0119)

        ];
        //机场专线
        var path_airLine = [
            new AMap.LngLat(116.593, 40.0795),
            new AMap.LngLat(116.616, 40.0531),
            new AMap.LngLat(116.457, 39.9614),
            new AMap.LngLat(116.435, 39.9424)

        ];
        //15号线
        var path_fifteen = [
            new AMap.LngLat(116.685, 40.1326),
            new AMap.LngLat(116.657, 40.13),
            new AMap.LngLat(116.641, 40.1299),
            new AMap.LngLat(116.609, 40.1284),
            new AMap.LngLat(116.564, 40.1141),
            new AMap.LngLat(116.558, 40.0844),
            new AMap.LngLat(116.555, 40.0701),
            new AMap.LngLat(116.535, 40.0452),
            new AMap.LngLat(116.504, 40.0338),
            new AMap.LngLat(116.493, 40.0223),
            new AMap.LngLat(116.487, 40.0018),
            new AMap.LngLat(116.468, 39.9973),
            new AMap.LngLat(116.447, 39.995),
            new AMap.LngLat(116.428, 40.0016),
            new AMap.LngLat(116.408, 40.0027),
            new AMap.LngLat(116.393, 40.0023),
            new AMap.LngLat(116.369, 40.0015),
            new AMap.LngLat(116.353, 40.001),
            new AMap.LngLat(116.339, 40.0007)

        ];
        // 6号线
        var path_six = [
            new AMap.LngLat(116.753, 39.9014),
            new AMap.LngLat(116.736, 39.9029),
            new AMap.LngLat(116.72, 39.9024),
            new AMap.LngLat(116.704, 39.902),
            new AMap.LngLat(116.69, 39.9028),
            new AMap.LngLat(116.677, 39.91),
            new AMap.LngLat(116.66, 39.9202),
            new AMap.LngLat(116.639, 39.9269),
            new AMap.LngLat(116.615, 39.9244),
            new AMap.LngLat(116.6, 39.9257),
            new AMap.LngLat(116.578, 39.9242),
            new AMap.LngLat(116.563, 39.924),
            new AMap.LngLat(116.518, 39.9232),
            new AMap.LngLat(116.502, 39.9231),
            new AMap.LngLat(116.478, 39.9229),
            new AMap.LngLat(116.462, 39.9232),
            new AMap.LngLat(116.452, 39.9231),
            new AMap.LngLat(116.433, 39.9244),
            new AMap.LngLat(116.417, 39.9244),
            new AMap.LngLat(116.403, 39.9331),
            new AMap.LngLat(116.387, 39.9333),
            new AMap.LngLat(116.372, 39.9327),
            new AMap.LngLat(116.355, 39.9324),
            new AMap.LngLat(116.344, 39.9325),
            new AMap.LngLat(116.325, 39.933),
            new AMap.LngLat(116.31, 39.9324),
            new AMap.LngLat(116.294, 39.933),
            new AMap.LngLat(116.277, 39.9326)

        ];
        //14号线中段
        var path_fourteen_middle = [
            new AMap.LngLat(116.478, 39.9156),
            new AMap.LngLat(116.478, 39.9083),
            new AMap.LngLat(116.478, 39.8932),
            new AMap.LngLat(116.477, 39.8844),
            new AMap.LngLat(116.477, 39.8757),
            new AMap.LngLat(116.47, 39.8679),
            new AMap.LngLat(116.458, 39.8659),
            new AMap.LngLat(116.433, 39.8658),
            new AMap.LngLat(116.422, 39.8657),
            new AMap.LngLat(116.409, 39.8651),
            new AMap.LngLat(116.399, 39.8683),
            new AMap.LngLat(116.388, 39.8713),
            new AMap.LngLat(116.379, 39.8652),
            new AMap.LngLat(116.365, 39.8627),
            new AMap.LngLat(116.354, 39.8611),
            new AMap.LngLat(116.343, 39.8681),
            new AMap.LngLat(116.336, 39.8681),
            new AMap.LngLat(116.321, 39.8679)

        ];
        //14号线东段
        var path_fourteen_east = [
            new AMap.LngLat(116.476, 40.0263),
            new AMap.LngLat(116.467, 40.0206),
            new AMap.LngLat(116.467, 40.0102),
            new AMap.LngLat(116.468, 39.9973),
            new AMap.LngLat(116.47, 39.9927),
            new AMap.LngLat(116.478, 39.9876),
            new AMap.LngLat(116.489, 39.9806),
            new AMap.LngLat(116.49, 39.9713),
            new AMap.LngLat(116.487, 39.9576),
            new AMap.LngLat(116.474, 39.9443),
            new AMap.LngLat(116.478, 39.9337),
            new AMap.LngLat(116.478, 39.9229)

        ];
        //14号线西段
        var path_fourteen_west = [
            new AMap.LngLat(116.304, 39.8665),
            new AMap.LngLat(116.294, 39.8675),
            new AMap.LngLat(116.276, 39.8652),
            new AMap.LngLat(116.253, 39.8644),
            new AMap.LngLat(116.24, 39.8592),
            new AMap.LngLat(116.202, 39.8613),
            new AMap.LngLat(116.187, 39.8584)

        ];

        // 创建折线实例
        var polyline_ten = new AMap.Polyline({
            path: path_ten,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#3366FF",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });

        // 创建折线实例
        var polyline_two = new AMap.Polyline({
            path: path_two,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#1975d1",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50
        });
        // 创建折线实例
        var polyline_thirteen = new AMap.Polyline({
            path: path_thirteen,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#ffd147",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_fs = new AMap.Polyline({
            path: path_fs,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#d94952",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_cp = new AMap.Polyline({
            path: path_cp,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#c9198e",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_nine = new AMap.Polyline({
            path: path_nine,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#b5d02a",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_bt = new AMap.Polyline({
            path: path_bt,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#d11919",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_one = new AMap.Polyline({
            path: path_one,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#d11919",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_yz = new AMap.Polyline({
            path: path_yz,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#ff4b1c",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_five = new AMap.Polyline({
            path: path_five,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#a31975",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 12],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_seven = new AMap.Polyline({
            path: path_seven,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#e97026",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_eight = new AMap.Polyline({
            path: path_eight,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#197547",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 12],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_four = new AMap.Polyline({
            path: path_four,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#19d1d1",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_airLine = new AMap.Polyline({
            path: path_airLine,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#bda3c3",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_fifteen = new AMap.Polyline({
            path: path_fifteen,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#6c3f78",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_six = new AMap.Polyline({
            path: path_six,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#eca32b",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_fourteen_middle = new AMap.Polyline({
            path: path_fourteen_middle,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#d79c94",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_fourteen_east = new AMap.Polyline({
            path: path_fourteen_east,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#d79c94",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });
        // 创建折线实例
        var polyline_fourteen_west = new AMap.Polyline({
            path: path_fourteen_west,
            isOutline: true,
            outlineColor: '#ffeeff',
            borderWeight: 3,
            strokeColor: "#d79c94",
            strokeOpacity: 0.8,
            strokeWeight: 6,
            // 折线样式还支持 'dashed'
            strokeStyle: "solid",
            // strokeStyle是dashed时有效
            strokeDasharray: [10, 5],
            lineJoin: 'round',
            lineCap: 'round',
            zIndex: 50,
        });

        // 将折线添加至地图实例
        this.map.add(polyline_ten);
        this.map.add(polyline_two);
        this.map.add(polyline_thirteen);
        this.map.add(polyline_fs);
        this.map.add(polyline_cp);
        this.map.add(polyline_nine);
        this.map.add(polyline_bt);
        this.map.add(polyline_one);
        this.map.add(polyline_yz);
        this.map.add(polyline_five);
        this.map.add(polyline_seven);
        this.map.add(polyline_eight);
        this.map.add(polyline_four);
        this.map.add(polyline_airLine);
        this.map.add(polyline_fifteen);
        this.map.add(polyline_six);
        this.map.add(polyline_fourteen_middle);
        this.map.add(polyline_fourteen_east);
        this.map.add(polyline_fourteen_west);
    };

    // this.addSubLine();

    var that = this;
    AMapUI.loadUI(['misc/MarkerList', 'overlay/SimpleMarker', 'overlay/SimpleInfoWindow'],
        function(MarkerList, SimpleMarker, SimpleInfoWindow) {

            //即jQuery/Zepto
            var $ = MarkerList.utils.$;

            var defaultIconStyle = 'red', //默认的图标样式
                hoverIconStyle = 'green', //鼠标hover时的样式
                selectedIconStyle = 'purple' //选中时的图标样式
            ;

            var markerList = new MarkerList({
                map: that.map,
                //ListElement对应的父节点或者ID
                listContainer: "myList", //document.getElementById("myList"),
                //选中后显示

                //从数据中读取位置, 返回lngLat
                getPosition: function(item) {
                    return [item.longitude, item.latitude];
                },
                //数据ID，如果不提供，默认使用数组索引，即index
                getDataId: function(item, index) {

                    return item.id;
                },
                getInfoWindow: function(data, context, recycledInfoWindow) {

                    var infoWindow = recycledInfoWindow;

                    if (infoWindow) {
                        infoWindow.setInfoTitle(data.name);
                        infoWindow.setInfoBody(data.brief + '<br><br>' + "项目地点：" + data.place + '<br><button class="in_project_btn">进入</button>');
                    } else {
                        infoWindow = new SimpleInfoWindow({
                            infoTitle: data.name,
                            infoBody: data.brief + '<br><br>' + "项目地点：" + data.place + '<br><button class="in_project_btn">进入</button>',
                            offset: new AMap.Pixel(0, -37)
                        });
                    }

                    infoWindow.get$InfoBody().off('click');
                    infoWindow.get$InfoBody().on('click', '.in_project_btn', function(event) {
                        event.stopPropagation();
                        if (options && options.enterProject) {
                            options.enterProject(data);
                        }
                    });
                    console.log(data.place);
                    return infoWindow;
                },
                //构造marker用的options对象, content和title支持模板，也可以是函数，返回marker实例，或者返回options对象
                getMarker: function(data, context, recycledMarker) {

                    var label = String.fromCharCode('A'.charCodeAt(0) + context.index);

                    if (recycledMarker) {
                        recycledMarker.setIconLabel(label);
                        return;
                    }

                    return new SimpleMarker({
                        containerClassNames: 'my-marker',
                        iconStyle: defaultIconStyle,
                        iconLabel: label
                    });
                },
                //构造列表元素，与getMarker类似，可以是函数，返回一个dom元素，或者模板 html string
                getListElement: function(data, context, recycledListElement) {

                    var label = String.fromCharCode('A'.charCodeAt(0) + context.index);

                    var shortBrief = data.brief == null ? "" : data.brief;
                    if (shortBrief.length > 50) shortBrief = shortBrief.substring(0, 50) + "...";
                    data.shortBrief = shortBrief;
                    //使用模板创建
                    var innerHTML = MarkerList.utils.template('<div class="poi-imgbox">' +
                        '    <span class="poi-img" style="background-image:url(<%- data.pic %>)"></span>' +
                        '</div>' +
                        '<div class="poi-info-left">' +
                        '    <h3 class="poi-title">' +
                        '        <%- label %>. <%- data.name %>' +
                        '    </h3>' +
                        '    <div class="poi-info">' +
                        '        <span class="poi-price" style="color:rgb(1000,100,0)">' +
                        '            <%= data.status %>' +
                        '        </span>' +
                        '        <p class="poi-addr" style="color:rgb(100,100,100)"><%- data.shortBrief %></p>' +
                        '    </div>' +
                        '</div>' +
                        '<div class="clear"></div>', {
                            data: data,
                            label: label
                        });

                    if (recycledListElement) {
                        recycledListElement.innerHTML = innerHTML;
                        return recycledListElement;
                    }

                    return '<li class="poibox">' +
                        innerHTML +
                        '</li>';
                },
                //列表节点上监听的事件
                listElementEvents: ['click', 'mouseenter', 'mouseleave'],
                //marker上监听的事件
                markerEvents: ['click', 'mouseover', 'mouseout'],
                //makeSelectedEvents:false,
                selectedClassNames: 'selected',
                autoSetFitView: true
            });

            window.markerList = markerList;

            markerList.on('selectedChanged', function(event, info) {

                if (info.selected) {
                    if (info.selected.marker) {
                        //更新为选中样式
                        info.selected.marker.setIconStyle(selectedIconStyle);
                    }

                    //选中并非由列表节点上的事件触发，将关联的列表节点移动到视野内
                    if (!info.sourceEventInfo.isListElementEvent) {

                        if (info.selected.listElement) {
                            scrollListElementIntoView($(info.selected.listElement));
                        }
                    }
                }

                if (info.unSelected && info.unSelected.marker) {
                    //更新为默认样式
                    info.unSelected.marker.setIconStyle(defaultIconStyle);
                }
            });

            markerList.setHoverMarkerIcon = function(marker) {
                forcusMarker(marker);
                marker.setIconStyle(hoverIconStyle);
            };

            markerList.setDefaultMarkerIcon = function(marker) {
                marker.setIconStyle(defaultIconStyle);
            };

            markerList.on('listElementMouseenter markerMouseover', function(event, record) {

                if (record && record.marker) {

                    forcusMarker(record.marker);

                    //this.openInfoWindowOnRecord(record);

                    //非选中的id
                    if (!this.isSelectedDataId(record.id)) {
                        //设置为hover样式
                        if (options.hoverRecord) {
                            options.hoverRecord(record);
                        }
                        record.marker.setIconStyle(hoverIconStyle);
                        //this.closeInfoWindow();
                    }
                }
            });

            markerList.on('listElementMouseleave markerMouseout', function(event, record) {

                if (record && record.marker) {

                    if (!this.isSelectedDataId(record.id)) {
                        //恢复默认样式
                        record.marker.setIconStyle(defaultIconStyle);
                    }
                }
            });

            //数据输出完成
            markerList.on('renderComplete', function(event, records) {

            });

            // markerList.on('*', function(type, event, res) {
            //     console.log(type, event, res);
            // });

            //加载数据
            function loadData(src, callback) {

                $.getJSON(src, function(data) {

                    markerList._dataSrc = src;

                    //渲染数据

                    markerList.render(data.data);

                    if (callback) {
                        callback(data.data);
                    }
                });
            }

            loadData(options.url, options.allProjectCallBack);

            function forcusMarker(marker) {
                marker.setTop(true);

                //不在地图视野内
                if (!(that.map.getBounds().contains(marker.getPosition()))) {

                    //移动到中心
                    that.map.setCenter(marker.getPosition());
                }
            }

            function isElementInViewport(el) {
                var rect = el.getBoundingClientRect();

                return (
                    rect.top >= 0 &&
                    rect.left >= 0 &&
                    rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
                    rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
                );
            }

            function scrollListElementIntoView($listEle) {

                if (!isElementInViewport($listEle.get(0))) {
                    $('#projectsListPanel').scrollTop($listEle.offset().top - $listEle.parent().offset().top);
                }

                //闪动一下
                $listEle
                    .one('webkitAnimationEnd oanimationend msAnimationEnd animationend',
                        function(e) {
                            $(this).removeClass('flash animated');
                        }).addClass('flash animated');
            }
        }
    );

    this.markerList = function() {
        return window.markerList;
    }

}